home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / knowhow4 / col_sbar.cpp < prev    next >
C/C++ Source or Header  |  1994-10-10  |  2KB  |  79 lines

  1. #include "col_sbar.h"
  2.  
  3. ColorScrollBar::ColorScrollBar(loc p, ORIENT type, int l,
  4.     int tot, int pg_size, int cur)
  5.     : ScrollBar(p, type, l, tot, pg_size, cur, 0)
  6.     {
  7.     }
  8. ////////////////////////////
  9. int ColorScrollBar::get_screen_pos(int)
  10.     {
  11.     return direction == VERT ? current : 2 * current;
  12.     }
  13. ////////////////////////////
  14. void ColorScrollBar::meter_show(loc m, int len, ORIENT direction,
  15.     int p, int)
  16.     {
  17.     loc corner = !direction ? loc(m.X + len, m.Y + 1)
  18.                            : loc(m.X + 2, m.Y + len);
  19.     rect r = screenRect(rect(m, corner));
  20.  
  21.     r.corner -= loc(2, 2);
  22.     for(int cl = 0; cl < 16; cl++)
  23.         {
  24.         setfillstyle(SOLID_FILL, cl);
  25.         rect r1 = !direction
  26.         ? rect(m.X + 2 * cl, m.Y, m.X + 2 * cl + 2, m.Y + 1)
  27.             : rect(m.X, m.Y + cl, m.X + 2, m.Y + cl + 1);
  28.         r1 = screenRect(r1);
  29.         bar(r1);
  30.     }
  31.     r.corner += loc(2, 2);
  32.  
  33.     Carcase c;
  34.     c.show(STANDART_BORDER, r);
  35.  
  36.     rect curs = !direction ? rect(m.X + p, m.Y,
  37.                                  m.X + p + 2, m.Y + 1)
  38.                           : rect(m.X, m.Y + p,
  39.                      m.X + 2, m.Y + p + 1);
  40.     rect r1 = screenRect(curs);
  41.     r1.symmexpand(loc(-1, -1));
  42.     Carcase c1;
  43.     c1.show(BUTTON_BORDER, r1);
  44.     }
  45. ////////////////////////////
  46. void ColorScrollBar::decrease()
  47.     {
  48.     global_i[0] = direction == HORIZ ? AC_HOME : AC_PG_UP;
  49.     current = direction == HORIZ
  50.         ? (e.where().X - screenXL(pos.X + 2)) / (2 * screenXL(1))
  51.         : (e.where().Y - screenYT(pos.Y + 1)) / screenYT(1);
  52.     show();
  53.     }
  54. /////////////////////////
  55. void ColorScrollBar::increase()
  56.     {
  57.     decrease();
  58.     }
  59. ////////////////////////////
  60. /*
  61. void main()
  62.     {
  63.     if(!init_KNOW_HOW())
  64.         return;
  65.     setfillstyle(SOLID_FILL, pColorSet->colors.BAK_COLOR);
  66.     bar(0, 0, getmaxx(), getmaxy());
  67.  
  68.     ColorScrollBar s(loc(10, 10), HORIZ, 36, 15, 1, 0);
  69.     s.show();
  70.     ColorScrollBar s1(loc(60, 5), VERT, 18, 15, 1, 0);
  71.     s1.show();
  72.  
  73.     s.exe();
  74.     s1.exe();
  75.  
  76.     close_KNOW_HOW();
  77.     closegraph();
  78.     }
  79. */